home *** CD-ROM | disk | FTP | other *** search
/ Champak 141 / (Vol 141) Oct 17 2011.iso / Games / dragon-runner.swf / scripts / ObstacleManager.as < prev    next >
Encoding:
Text File  |  2011-10-17  |  5.8 KB  |  194 lines

  1. package
  2. {
  3.    import flash.display.MovieClip;
  4.    import flash.display.Sprite;
  5.    import flash.events.Event;
  6.    
  7.    public class ObstacleManager extends Sprite
  8.    {
  9.        
  10.       
  11.       private var ┬º\x01\x01\x02\t┬º:* = null;
  12.       
  13.       private var ┬º\x01\x01\x06\x0b┬º:* = null;
  14.       
  15.       private var ┬º\x01\x01\x02\r┬º:* = null;
  16.       
  17.       internal const OBTSPACEDEC:* = 0.3;
  18.       
  19.       internal const DOC_HEIGHT:* = 400;
  20.       
  21.       internal const OBTHEIGHT:* = 62.5;
  22.       
  23.       internal const OBTWIDTH:* = 60;
  24.       
  25.       public var theKnight:*;
  26.       
  27.       private var ┬º\x01\x01\x06\r┬º:* = null;
  28.       
  29.       internal const DOC_TOP:* = 0;
  30.       
  31.       internal const OBTSPACE:* = 400;
  32.       
  33.       private var ┬º\x01\x01\x06\x0f┬º:Number;
  34.       
  35.       private var ┬º\x01\x01\x04\x0e┬º:Boolean = false;
  36.       
  37.       internal const OBTYPOS:* = 268.75;
  38.       
  39.       private var ┬º\x01\x01\x03\x0e┬º:* = null;
  40.       
  41.       internal const DOC_WIDTH:* = 640;
  42.       
  43.       public var obstacleCount:int = 0;
  44.       
  45.       internal const DOC_LEFT:* = 0;
  46.       
  47.       internal const OBTCOUNTMAX:* = 200;
  48.       
  49.       private var ┬º\x01\x01\x07\x01┬º:*;
  50.       
  51.       public var theDragon:*;
  52.       
  53.       internal const OBTFACECOUNT:* = 5 + 1;
  54.       
  55.       private var ┬º\x01\x01\x07\x03┬º:Number;
  56.       
  57.       public function ObstacleManager(param1:*, param2:*, param3:*)
  58.       {
  59.          ┬º\x01\x01\x04\x0e┬º = false;
  60.          ┬º\x01\x01\x02\t┬º = null;
  61.          ┬º\x01\x01\x02\r┬º = null;
  62.          ┬º\x01\x01\x03\x0e┬º = null;
  63.          ┬º\x01\x01\x06\r┬º = null;
  64.          ┬º\x01\x01\x06\x0b┬º = null;
  65.          obstacleCount = 0;
  66.          super();
  67.          ┬º\x01\x01\x02\t┬º = param1;
  68.          ┬º\x01\x01\x02\r┬º = param2;
  69.          ┬º\x01\x01\x03\x0e┬º = param3;
  70.          ┬º\x01\x01\x06\r┬º = ┬º\x01\x01\x02\r┬º.GetSceneContainer();
  71.          ┬º\x01\x01\x07\x03┬º = ┬º\x01\x01\x02\r┬º.GetFrontScrollSpeed();
  72.       }
  73.       
  74.       public function StopGame() : *
  75.       {
  76.          ┬º\x01\x01\x06\x10┬º();
  77.          ┬º\x01\x01\x02\t┬º.removeEventListener(Event.ENTER_FRAME,┬º\x01\x01\x06\x0e┬º);
  78.       }
  79.       
  80.       private function ┬º\x01\x01\x06\f┬º() : *
  81.       {
  82.          var _loc1_:int = 0;
  83.          if(theDragon.GetDragonStatus() == 0)
  84.          {
  85.             if(┬º\x01\x01\x06\x0b┬º != null)
  86.             {
  87.                _loc1_ = ┬º\x01\x01\x07\x02┬º();
  88.                if(_loc1_ < OBTFACECOUNT)
  89.                {
  90.                   ┬º\x01\x01\x06\x0b┬º = new obstacle();
  91.                   ┬º\x01\x01\x06\x0b┬º.Init(┬º\x01\x01\x02\t┬º,┬º\x01\x01\x06\r┬º,this);
  92.                   ┬º\x01\x01\x06\x0b┬º.x = 640;
  93.                   ┬º\x01\x01\x06\x0b┬º.ShowFace(_loc1_);
  94.                }
  95.                else
  96.                {
  97.                   ┬º\x01\x01\x06\x0b┬º = new bird();
  98.                   ┬º\x01\x01\x06\x0b┬º.Init(┬º\x01\x01\x02\t┬º,┬º\x01\x01\x06\r┬º,this);
  99.                   ┬º\x01\x01\x06\x0b┬º.x = 640;
  100.                }
  101.                ┬º\x01\x01\x06\r┬º.addChild(┬º\x01\x01\x06\x0b┬º);
  102.                --┬º\x01\x01\x06\x0f┬º;
  103.                ++obstacleCount;
  104.             }
  105.             else
  106.             {
  107.                _loc1_ = 5;
  108.                ┬º\x01\x01\x06\x0b┬º = new obstacle();
  109.                ┬º\x01\x01\x06\x0b┬º.Init(┬º\x01\x01\x02\t┬º,┬º\x01\x01\x06\r┬º,this);
  110.                if(obstacleCount == 0)
  111.                {
  112.                   ┬º\x01\x01\x06\x0b┬º.x = 840;
  113.                }
  114.                else
  115.                {
  116.                   ┬º\x01\x01\x06\x0b┬º.x = 640;
  117.                }
  118.                ┬º\x01\x01\x06\x0b┬º.ShowFace(_loc1_);
  119.                ┬º\x01\x01\x06\r┬º.addChild(┬º\x01\x01\x06\x0b┬º);
  120.                --┬º\x01\x01\x06\x0f┬º;
  121.                ++obstacleCount;
  122.             }
  123.          }
  124.       }
  125.       
  126.       public function StartGame() : *
  127.       {
  128.          if(┬º\x01\x01\x03\x0e┬º.mainChar)
  129.          {
  130.             theKnight = ┬º\x01\x01\x03\x0e┬º.mainChar;
  131.          }
  132.          if(┬º\x01\x01\x03\x0e┬º.enemyChar)
  133.          {
  134.             theDragon = ┬º\x01\x01\x03\x0e┬º.enemyChar;
  135.          }
  136.          ┬º\x01\x01\x06\x0f┬º = OBTSPACE;
  137.          obstacleCount = 0;
  138.          ┬º\x01\x01\x06\x0b┬º = null;
  139.          ┬º\x01\x01\x02\t┬º.addEventListener(Event.ENTER_FRAME,┬º\x01\x01\x06\x0e┬º,false,0,true);
  140.       }
  141.       
  142.       private function ┬º\x01\x01\x06\x0e┬º(param1:Event) : *
  143.       {
  144.          if(obstacleCount < OBTCOUNTMAX)
  145.          {
  146.             if(!┬º\x01\x01\x06\x0b┬º)
  147.             {
  148.                ┬º\x01\x01\x06\f┬º();
  149.             }
  150.             else if(┬º\x01\x01\x06\x0b┬º.x < DOC_WIDTH - ┬º\x01\x01\x06\x0f┬º || !┬º\x01\x01\x06\x0b┬º.GetLive())
  151.             {
  152.                ┬º\x01\x01\x06\f┬º();
  153.             }
  154.          }
  155.          else
  156.          {
  157.             ┬º\x01\x01\x03\x0e┬º.StopGame(false);
  158.          }
  159.       }
  160.       
  161.       public function DestroyObstacle(param1:MovieClip) : *
  162.       {
  163.          if(┬º\x01\x01\x06\x0b┬º == param1)
  164.          {
  165.             ┬º\x01\x01\x06\x0b┬º = null;
  166.          }
  167.          param1.Destroy();
  168.          ┬º\x01\x01\x06\r┬º.removeChild(param1);
  169.       }
  170.       
  171.       private function ┬º\x01\x01\x06\x10┬º() : *
  172.       {
  173.          var _loc1_:int = 0;
  174.          _loc1_ = 0;
  175.          while(_loc1_ < ┬º\x01\x01\x06\r┬º.numChildren)
  176.          {
  177.             if(┬º\x01\x01\x06\r┬º.getChildAt(_loc1_).GetCharType == "obstacle" || ┬º\x01\x01\x06\r┬º.getChildAt(_loc1_).GetCharType == "bird")
  178.             {
  179.                DestroyObstacle(┬º\x01\x01\x06\r┬º.getChildAt(_loc1_));
  180.             }
  181.             _loc1_++;
  182.          }
  183.       }
  184.       
  185.       private function ┬º\x01\x01\x07\x02┬º() : int
  186.       {
  187.          var _loc1_:int = 0;
  188.          var _loc2_:String = null;
  189.          _loc1_ = 0;
  190.          return int(Math.random() * OBTFACECOUNT + 1);
  191.       }
  192.    }
  193. }
  194.